package com.OnTimeTeam.OnTime;

import android.app.ProgressDialog;
import android.os.AsyncTask;

public class RoadQueryOnBackground extends AsyncTask<String, Void, RoadsQuery> {

    ProgressDialog progressDialog;
   
	private SetSmart host;
	RoadsQuery roadsQ;
	
	public RoadQueryOnBackground(SetSmart host){
		this.host = host;
	}
	
	//Transit
	public RoadQueryOnBackground(SetSmart host,  RoadsQuery roadsQ){
		this.host = host;
		this.roadsQ = roadsQ;
	}
	
    protected RoadsQuery doInBackground(String... params) {//In Background
    	
    	//roadsQ already initialized on C'tor in case of using Transit
    	if(roadsQ == null)
    		 roadsQ = new RegularRoadsQuery(params[0], params[1], true, params[2]);
    	
		roadsQ.setParameters();
    	return roadsQ;
    }      

    protected void onPreExecute() {//Before
    	super.onPreExecute();

    	progressDialog = ProgressDialog.show(host, host.getResources().getString(R.string.calculating), host.getResources().getString(R.string.pleaseWait));
    }
    
    protected void onPostExecute(RoadsQuery result) {//After
    	progressDialog.dismiss();
    	host.confirmationDialogBox(result);
    }



    protected void onProgressUpdate(Void... values) {
    	
    	
    }
}

